package com.otherTest.Math;

import org.junit.Test;

/**
 * 测试sponge流量算法
 *
 * @author Conceit
 * @since 1.0 2017/7/26
 */
public class TestSpongeFlowData {

    /**
     * 测试井下流量也为采集器 高于半径 算法
     * 高于半径小于直径
     * 三角面积加上扇形面积就是流量面积
     * 流量面积*流速就是当前的流量
     *
     * @return 返回类型
     */
    @Test
    public void testLiquidHeightExceedRadius() {
        double radius = 0.825;
        double diameter = 1.65;
        double liquidHeight = Double.valueOf((double) 1233 / 1000);
        double flowVelocity = Double.valueOf(1.03);

        //2.10696909790467 角度
        double angle = 2 * Math.acos((liquidHeight - (0 + radius)) / radius);
        System.out.println(angle);
        //2.125732001797092 扇形面积
        double sectorArea = (((360 - angle) / 360) *
                ((Math.PI * (Math.pow(diameter, 2))) / 4));
        System.out.println("扇形面积" + sectorArea);
        //0.292556484638437三角形面积
        double triangleArea = ((Math.pow(diameter, 2)) / 4) *
                (Math.sin(angle / 2)) *
                (Math.cos(angle / 2));
        System.out.println("三角形面积" + triangleArea);
        //液位面积
        double liquidArea = sectorArea + triangleArea;
        System.out.println(liquidArea);
        //液位面积*流速=流量
        double flowData = liquidArea * flowVelocity;
        System.out.println(flowData);
    }

    /**
     * 测试井下流量也为采集器 高于半径 算法
     * 小于半径  大于0
     * 扇形面积-三角面积就是流量面积
     * 流量面积*流速就是当前的流量
     *
     * @return 返回类型
     */
    @Test
    public void testLiquidHeightLessRadius() {
        //半径
        double radius = 0.825;
        //直径
        double diameter = 1.65;
        //液位
        double liquidHeight = Double.valueOf((double) 600 / 1000);
        //流速
        double flowVelocity = Double.valueOf(1.03);
        //高程
        double elevation = 0;
        //角度 0.6
        double angle = new Double(2) * Math.acos((elevation - liquidHeight + radius) / radius);
        System.out.println("角度" + angle);
        //扇形面积 0.01537838400750132
        double sectorArea = (angle / 360) * ((Math.PI * (Math.pow(diameter, 2))) / 4);
        System.out.println("扇形面积" + sectorArea);
        //三角面积 0.10823528090718777
        double triangleArea = (diameter / 4) * (Math.sin(angle / 2)) * (Math.cos(angle / 2));
        System.out.println("三角面积" + triangleArea);
        //扇形面积-三角面积就是流量面积 -0.09285689689968646
        double liquidArea = sectorArea - triangleArea;
        System.out.println("流量面积" + liquidArea);
        double totalArea = Math.PI * (Math.pow(diameter, 2));
        System.out.println("该设备总面积" + totalArea);
        //自算扇形面积 (圆心角/360)π*半径平方 与理工大结果一致扇形面积
        double custemSectorArea = (angle / 360) * Math.PI * (Math.pow(radius, 2));
        //System.out.println(custemSectorArea);


    }

    /**
     * 使用超哥算法实现小于半径
     */
    @Test
    public void testJeffLessRadius() {
        //半径
        double radius = 0.825;
        //直径
        double diameter = 1.65;
        //液位
        double liquidHeight = Double.valueOf((double) 200 / 1000);
        //流速
        double flowVelocity = Double.valueOf(1.03);
        //高程
        double elevation = 0;
        //计算面积 也为小于半径
//         area = Math.pow(r, 2) * Math.acos((h - r) / r)
//                 - (h - r) * Math.sqrt(Math.pow(r, 2) - Math.pow(h - r, 2));

        double area;
        area = Math.pow(radius, new Double(2)) * Math.acos((liquidHeight - radius) / radius)
                - (liquidHeight - radius) * Math.sqrt(Math.pow(radius, new Double(2)) - Math.pow(liquidHeight - radius, new Double(2)));
        double result = area * flowVelocity;
        System.out.println("流量面积为" + area);
        System.out.println("流量为" + result);
        //。。
    }

    /**
     * 使用超哥算法实现大于半径
     */
    @Test
    public void testJeffExceedRadius() {
        //半径
        double radius = 0.825;
        //直径
        double diameter = 1.65;
        //液位
        double liquidHeight = Double.valueOf((double) 1600 / 1000);
        //流速
        double flowVelocity = Double.valueOf(1.03);
        //高程
        double elevation = 0;

//        area = Math.PI * Math.pow(r, 2)
//                - Math.pow(r, 2) * Math.acos((h - r) / r)
//                + (h - r) * Math.sqrt(Math.pow(r, 2) - Math.pow(h - r, 2));
        double area;
        area = Math.PI * Math.pow(radius, 2)
                - Math.pow(radius, 2) * Math.acos((liquidHeight - radius) / radius)
                + (liquidHeight - radius) * Math.sqrt(Math.pow(radius, 2) - Math.pow(liquidHeight - radius, 2));
        double result = area * flowVelocity;
        System.out.println("流量面积为" + area);
        System.out.println("流量为" + result);
    }


    @Test
    public void testMonomer() {
        //原始液位数据毫米转为计算中的米
        double liquidHeight = (double) 200 / 1000;
        double flowData = (8.00 / 15.00) * 0.6 * Math.toDegrees(Math.tan(30.00 / 2.00)) * Math.sqrt(2 * 9.808) * Math.pow(liquidHeight, 5.00 / 2.00);
        System.out.println("液位：" + liquidHeight);
        System.out.println("流量：" + flowData);

        double one = (8.00 / 15.00) * 0.6;
        System.out.println("one    " + one);
        double two = Math.tan(30 / 2 * Math.PI / 180);//应该是0.2679491924
        System.out.println("two    " + two);
        double three = Math.sqrt(2 * 9.808);
        System.out.println("three  " + three);
        double four = Math.pow(liquidHeight, 5.00 / 2.00);
        System.out.println("four  " + four);
        System.out.println(one * two * three * four);
    }

    /**
     * 井下流量小于半径的算法
     */
    @Test
    public void testLessRadius() {
        //液位高
        Double height = 1.0;
        System.out.println("液位高" + height);
        //半径
        Double radius = 2.0;
        System.out.println("半径" + radius);
        //三角形高
        Double triangleHeight = radius - height;
        System.out.println("三角形高" + triangleHeight);
        //三角形底边
        Double bottomEdge = Math.pow(radius, 2) - Math.pow(triangleHeight, 2);
        System.out.println("三角形底边" + bottomEdge);
        //三角形面积
        Double triangleArea = triangleHeight * bottomEdge;
        System.out.println("大三角形面积" + triangleArea);

        //三角形小角
        Double triangleMinAngle = Math.toDegrees(Math.asin(triangleHeight / radius));
        System.out.println("三角形小角" + triangleMinAngle);
        //扇形角
        Double sectorAngle = 180 - triangleMinAngle * 2;
        System.out.println("扇形角" + sectorAngle);
        //扇形角绝对值
        Double sectorAbsAngle = Math.abs(sectorAngle);
        System.out.println("扇形角绝对值" + sectorAbsAngle);
        //扇形面积
//        Double sectorArea=sectorAngle* 0.825;
//        System.out.println("扇形面积"+sectorArea);
        //另一种扇形面积
        Double custemSectorArea = sectorAngle / 360 * Math.PI * Math.pow(radius, 2);
        System.out.println("另一种扇形面积" + custemSectorArea);
        //液位面积
        System.out.println();
    }

    /**
     * 井下流量大于半径的算法
     */
    @Test
    public void testExceedRadius() {

        //液位高
        Double height = 1.00;
        System.out.println("液位高" + height);
        //半径
        Double radius = 0.825;
        System.out.println("半径" + radius);
        //圆形面积
        System.out.println("圆形面积" + Math.PI * radius * radius);
        //三角形高
        Double triangleHeight = height - radius;
        System.out.println("三角形高" + triangleHeight);
        //三角形底边
        Double bottomEdge = Math.sqrt(Math.pow(radius, 2) - Math.pow(triangleHeight, 2));
        System.out.println("三角形底边" + bottomEdge);
        //三角形面积
        Double triangleArea = triangleHeight * bottomEdge;
        System.out.println("大三角形面积" + triangleArea);

        //三角形小角
        Double triangleMinAngle = Math.toDegrees(Math.asin(triangleHeight / radius));
        System.out.println("三角形小角" + triangleMinAngle);

        //扇形角
        Double sectorAngle = 180 - triangleMinAngle * 2;
        System.out.println("扇形角" + sectorAngle);
        //扇形角绝对值
        Double sectorAbsAngle = Math.abs(sectorAngle);
        System.out.println("扇形角绝对值" + sectorAbsAngle);

        //

        //扇形面积
        Double custemSectorArea = (360 - sectorAbsAngle) / 360 * Math.PI * Math.pow(radius, 2);
        System.out.println(Math.PI * Math.pow(radius, 2));
        System.out.println((360 - sectorAbsAngle) / 360);

        System.out.println("另一种扇形面积" + custemSectorArea);

        //流量面积
        Double liquidArea = custemSectorArea + triangleArea;
        System.out.println("流量面积" + liquidArea);

        //

        //流量
        Double flowData = liquidArea;
    }

    @Test
    public void test() {
        System.out.println(Math.pow(2, 3));
    }


}
